package com.weightx.weight.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.List;

import com.weightx.weight.entity.UserExcel;
import com.weightx.weight.properties.DownloadProperties;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xmlgraphics.util.DateFormatUtil;

public class ExcelWriter {

    public static void writeUserExcel(List<UserExcel> dataList, String fileName) throws IOException {
//        XSSFWorkbook workbook = new XSSFWorkbook();
//        Sheet sheet = workbook.createSheet("Data");
//
//        int rowNum = 0;
//        Row headerRow = sheet.createRow(rowNum++);
//        headerRow.createCell(0).setCellValue("UnionID");
//        headerRow.createCell(1).setCellValue("首次登录日期");
//        headerRow.createCell(2).setCellValue("最近一次登录日期");
//        headerRow.createCell(3).setCellValue("最近30天记录天数");
//        headerRow.createCell(4).setCellValue("总记录的天数");
//        headerRow.createCell(5).setCellValue("目标体重");
//        headerRow.createCell(6).setCellValue("设置单位");
//        headerRow.createCell(7).setCellValue("身高");
//        headerRow.createCell(8).setCellValue("性别");
//        headerRow.createCell(9).setCellValue("出身年份");
//
//        for (UserExcel data : dataList) {
//            Row row = sheet.createRow(rowNum++);
//            row.createCell(0).setCellValue(data.getOpenid());
//            row.createCell(1).setCellValue(DateUtils.formatDate(data.getRegisterTime()));
//            row.createCell(2).setCellValue(DateUtils.formatDate(data.getLoginTime()));
//            row.createCell(3).setCellValue(data.getAddNum30());
//            row.createCell(4).setCellValue(data.getAddNumAll());
//            row.createCell(5).setCellValue(data.getTargetWeight() == null ? "null" : data.getTargetWeight().toString());
//            row.createCell(6).setCellValue(data.getUnit() == 0 ? "千克" : "斤");
//            row.createCell(7).setCellValue(data.getBodyHeight() == null ? "null" : data.getBodyHeight().toString());
//            row.createCell(8).setCellValue(data.getSex() == null ? "null" : (data.getSex() == 0 ? "男" : "女"));
//            row.createCell(9).setCellValue(data.getBirth() == null ? "null" : DateUtils.formatYear(data.getBirth()));
//        }
//
//        // 输出Excel文件
//        try (FileOutputStream outputStream = new FileOutputStream(fileName)) {
//            workbook.write(outputStream);
//        }
    }

}
